﻿using System.Collections.Generic;
using System.Text;
using WinnerCMS.BLL;
using WinnerCMS.BLL.PageFactory.TagModule;
using WinnerCMS.Common;
using WinnerCMS.Model;

namespace WinnerCMS.WebFactory
{
    public static class CommentCommon
    {

        #region 评论
        /// <summary>
        /// 评论
        /// </summary>
        /// <param name="strWebString"></param>
        /// <param name="ContentID"></param>
        /// <returns></returns>
        static public string CommentShow(string TemplateString, int ContentID)
        {
            string strMode = TemplateString;
            int Rows = TagEngine.GetValue<int>(strMode, "Rows"); 

            IList<Comment> list = new CommentManage().CommentShow(Rows, ContentID);

            StringBuilder TempStrBuilder = new StringBuilder();
            strMode = TagEngine.GetString(TemplateString, "CommentShow", GetWhich.ItemTemplate);
            if (list.Count > 0)
            {
                foreach (Comment model in list)
                {
                    TempStrBuilder.Append(strMode);

                    PageCommon.RepalceFiled(TempStrBuilder, model);
                }
            }
            else
            {
                string _Temp = TagEngine.GetString(TemplateString, "CommentShow", GetWhich.EmptyDataTemplate);
                if (_Temp.Length == 0)
                    TempStrBuilder.Append("没有公告！");
                else
                    TempStrBuilder.Append(_Temp);
            }
             

            return TempStrBuilder.ToString();
        }
        #endregion


    }
}